
/*
 * Copyright (C) 2008-2009 Archie L. Cobbs. All rights reserved.
 *
 * $Id: ListReader.java 218 2009-11-19 18:01:57Z archie.cobbs $
 */

package org.dellroad.sidekar.annotation;

import java.lang.reflect.Method;
import java.util.Set;

import org.dellroad.sidekar.schema.model.ListFieldModel;
import org.dellroad.stuff.util.LinkedList;

/**
 * Introspects {@link SidekarList} annotations.
 */
class ListReader extends CollectionReader {

    /**
     * Look for {@link SidekarList} annotations and process them.
     */
    @Override
    public void process(Class<?> entityClass, Set<Method> methods) {
        for (Method method : methods) {
            SidekarList sidekarList = method.getAnnotation(SidekarList.class);
            if (sidekarList != null)
                this.processListAnnotation(sidekarList, method);
        }
    }

    private void processListAnnotation(SidekarList a, Method method) {
        this.processAccessAnnotation(a, method, a.value(), new ListFieldModel(), LinkedList.class);
    }
}

